﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DeloUtils
{
    public partial class frmApiConnect : Form
    {
        public frmApiConnect()
        {
            InitializeComponent();
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                Type tp = Type.GetTypeFromProgID("EApi.Head");
                EApi.Head ApiConnection = (EApi.Head)Activator.CreateInstance(tp);
                ((frmMain)(this.Owner)).ApiConnection = ApiConnection;
                if (ApiConnection.OpenWithParamsEx(txtServer.Text, txtOwner.Text, txtUser.Text, txtPassword.Text))
                {
                    MessageBox.Show("Подключение удалось!");
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Подключение не удалось!\n"+ApiConnection.ErrText);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка! \n"+ ex.Message);
            }
        }
    }
}
